package utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class JdbcUtils {
    private static DataSource ds ;

    static {
        try {
            Properties pro = new Properties();
            String path = JdbcUtils.class.getClassLoader( ).getResource("druid.properties").getPath( );
            pro.load(new FileInputStream(path));
             ds = DruidDataSourceFactory.createDataSource(pro);
        } catch (IOException e) {
            e.printStackTrace( );
        } catch (Exception e) {
            e.printStackTrace( );
        }
    }

    public static DataSource getDataSource(){
        return ds ;
    }
}
